local zhenjun = fk.CreateSkill {
  name = "ls__zhenjun",
  tags = {"Phase"}
}

Fk:loadTranslationTable{
  ["ls__zhenjun"] = "镇军",
  [":ls__zhenjun"] = "阶段技，你可将两张相同颜色的手牌或中央区内的牌当勇策略【无中生有】使用并移去这些牌。",

  ["$ls__zhenjun1"] = "以饱待饥，以赏待虚。",
  ["$ls__zhenjun2"] = "命授节钺，调兵遣将。",
}
local DIY = require "packages/diy_utility/diy_utility"

zhenjun:addAcquireEffect(function (self, player, is_start)
  player.room:addSkill("#CenterArea")
end)

zhenjun:addEffect("viewas", {
  anim_type = "control",
  pattern = "ex_nihilo",
  handly_pile = true,
  max_phase_use_time = 1,
  expand_pile = function (self, player)
    return DIY.getCenterCards(Fk:currentRoom())
  end,
  card_filter = function(self, player, to_select, selected)
    if #selected == 0 then
      return not table.contains(player:getCardIds("e"), to_select)
    else
      return Fk:getCardById(to_select).color == Fk:getCardById(selected[1]).color
    end
  end,
  view_as = function(self, player, cards)
    if #cards ~= 2 then return end
    local c = Fk:cloneCard("lvshi__ex_nihilo")
    c.skillName = zhenjun.name
    c:addSubcards(cards)
    return c
  end,
  enabled_at_play = function (self, player)
    return player:usedSkillTimes(zhenjun.name, Player.HistoryPhase) == 0
  end,
})

zhenjun:addEffect(fk.CardUsing, {
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(zhenjun.name) and target == player and data.card.skillName == zhenjun.name
  end,
  on_use = function(self, event, target, player, data)
    data.extra_data = data.extra_data or {}
    data.extra_data.strategy = "ex_nihilo_courage"
    DIY.removeCenterCards(player, player.room:getSubcardsByRule(data.card))
    for _, id in ipairs(player.room:getSubcardsByRule(data.card)) do
      player.room:setCardMark(Fk:getCardById(id), MarkEnum.RemoveCenterCards.."-turn", 1)
    end
  end,
})


return zhenjun